﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CommonLib;
public class SkillLogic : MonoBehaviour, IInitFromConfig
{
	//TODO
	[SerializeField]
	UIView_GamePlay gamePlay;

	protected GamePlayFacade Parent { get; set; }
	protected List<Skill> LstChargingSkill { get; set; }
	protected List<Skill> LstCurrentSkill { get; set; }
	protected int MaxSkillCount { get; set; }

	public void Init(GamePlayFacade parent)
	{
		this.Parent = parent;
		LstChargingSkill = new List<Skill>();
		LstCurrentSkill = new List<Skill>();
		MaxSkillCount = gamePlay.SlotCount;
	}

	public void DoUpdate(float deltaTime)
	{
		for (int index = 0; index < LstChargingSkill.Count; index++)
		{
			if (!LstChargingSkill[index].IsActive)
				LstChargingSkill[index].DoCharge(deltaTime);
			else
			{
				LstChargingSkill.RemoveAt(index);
				index--;
			}
		}
	}

	public void AddChargeSkill( Skill skill)
	{
		LstChargingSkill.Add(skill);
	}




	public void AddSkill(RoleCtrl role, string key)
	{
		//if(LstCurrentSkill.Count <= MaxSkillCount - 1)
		//{
		//	LstCurrentSkill.Add(skill);
		//	//gamePlay.AddSkill();
		//}
	}
	
	public void RemoveSkil(Skill skill)
	{
		//if (LstCurrentSkill.Contains(skill))
		//	LstCurrentSkill.Remove(skill);
	}

	public void Clear() { }

	public void _ConfigInit(string _fileName)
	{
		throw new System.NotImplementedException();
	}
}
